<html>
<head><meta charset="utf-8"><title>Intrinsic usage without target_feature(enable...) · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Intrinsic.20usage.20without.20target_feature(enable.2E.2E.2E).html">Intrinsic usage without target_feature(enable...)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197224174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Intrinsic%20usage%20without%20target_feature%28enable...%29/near/197224174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Intrinsic.20usage.20without.20target_feature(enable.2E.2E.2E).html#197224174">(May 12 2020 at 00:54)</a>:</h4>
<p><a href="https://www.reddit.com/r/rust/comments/ghwxml/rust_target_features_performance_pitfall/">It was said on reddit</a> that if you call an intrinsic without the appropriate feature enabled on the function (or in the crate's overall build) LLVM will convert your intrinsic call to equivalent scalar code.</p>
<p>Is this true? If so, that seems like a major performance pitfall that should have a lint or something.</p>



<a name="197225045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Intrinsic%20usage%20without%20target_feature%28enable...%29/near/197225045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BurntSushi <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Intrinsic.20usage.20without.20target_feature(enable.2E.2E.2E).html#197225045">(May 12 2020 at 01:10)</a>:</h4>
<p>try it. any time i've made that mistake, profiling has made it clear because the corresponding intrinsics don't get inlined and things are very slow.</p>
<p>the RFC for target feature 1.1 is meant to address this IIRC. "just add a lint" isn't so easy.</p>



<a name="197226740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Intrinsic%20usage%20without%20target_feature%28enable...%29/near/197226740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Intrinsic.20usage.20without.20target_feature(enable.2E.2E.2E).html#197226740">(May 12 2020 at 01:44)</a>:</h4>
<p>AFAIK "it gets converted to scalar code" is false. It's just that the intrinsic won't be inlined due to the CPU feature mismatch.</p>



<a name="197236311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Intrinsic%20usage%20without%20target_feature%28enable...%29/near/197236311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Intrinsic.20usage.20without.20target_feature(enable.2E.2E.2E).html#197236311">(May 12 2020 at 05:56)</a>:</h4>
<p>Okay, it's what Amanieu said, &lt;<a href="https://rust.godbolt.org/z/Wb-2ci">https://rust.godbolt.org/z/Wb-2ci</a>&gt;</p>
<p>Though I still feel like a lint would be appropriate here.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>